const express = require("express");
const app = express();

// 数据
const students = [
  { id: "001", name: "tom", age: 18 },
  { id: "002", name: "jerry", age: 19 },
  { id: "003", name: "tony", age: 120 },
];

// 配置解析表单数据的中间件
app.use((request, response, next) => {
  console.log("请求服务器了");
  next();
});

app.get("/students", (request, response) => {
  response.send(students);
});

app.listen(5000, (err) => {
  if (!err) console.log("服务器启动");
});
